import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner scanner = new Scanner(System.in);
    static int N = scanner.nextInt();
    static int[] a = new int[N];//a[i]表示第i行的棋子在第几列
    static int ans = 0;

    public static void main(String[] args) {
        Arrays.fill(a,-1);
        dfs(0);
        System.out.println(ans);
    }

    private static void dfs(int row) {
        if (row == N){
            ans++;
            return;
        }
        for (int i = 0; i < N; i++) {
            if (a[row] == -1){
                //检查当前格子能否存放棋子
                if (check(row,i)){
                    a[row] = i;
                    dfs(row+1);
                    a[row] = -1;
                }
            }
        }
    }

    private static boolean check(int row, int col) {
        for (int i = 0; i < row; i++) {
            if (a[i] == col){
                return false;
            }
            if (i + a[i] == row + col){
                return false;
            }
            if (i - a[i] == row - col){
                return false;
            }
        }
        return true;
    }

}
